﻿@using Super.DomainService
@using Super.Web.Areas.Admin.Controllers
@model List<Stock>
@{
    Layout = null;

    List<ProductCategory> categoryList = (List<ProductCategory>)ViewBag.categoryList;
    List<DiyItem> diyitems = (List<DiyItem>)ViewBag.DiyItems;
}
<!DOCTYPE html>
<html>
<head>
    <title>模拟装机</title>
    <link href="/Areas/Admin/Assets/style/Diy_index.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="/Areas/Admin/Assets/style/proFilter.css" rel="stylesheet" type="text/css" media="screen" />
    <script src="/Areas/Admin/Assets/script/jquery-1.7.1.js" type="text/javascript"></script>
</head>
<body>
    <div class="wrapper">
        <div class="pc_parts_select">
            <div class="sel_title">
                <strong>请选择配件</strong>
            </div>
            <ul class="pc_parts_option clearfix" id="topSubSel">
                @{
                    // class=done,cur
                    if (categoryList != null)
                    {
                        foreach (var item in categoryList)
                        {
                    <li class="" id="topSubSel_@(item.ID)" rel="@item.ID"><span>@item.Name</span></li>
                        }
                    }
                }
            </ul>
        </div>
        <div class="diy_box" id="diy_content">
            <div class="your_card">
                <h3 class="your_card_hd">装机配置单</h3>
                <div class="card_head">
                    <table>
                        <tbody>
                            <tr>
                                <th class="type">配置</th>
                                <th class="name">品牌型号</th>
                                <th class="num">数量</th>
                                <th class="price">价格</th>
                                <th>操作</th>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <ul class="card_detail" id="leftSelBox">
                    @{
                        var mustChonese = new List<string> { "CPU", "主板", "内存", "硬盘" };
                        if (categoryList != null)
                        {
                            foreach (var item in categoryList)
                            {
                                DiyItem diyitem = null;
                                int diyitemCount = 0;
                                if (diyitems != null)
                                {
                                    diyitem = diyitems.FirstOrDefault(a => a.CategoryId == item.ID);
                                    diyitemCount = diyitems.Count(a => a.CategoryId == item.ID);
                                }
                                
                        <li class="leftSubSel" rel="@item.ID" id="leftSubSel_@(item.ID)"><span class="item"><a name="s_@(item.ID)"></a>@item.Name
                            @if (mustChonese.Contains(item.Name))
                            {
                                <em>*</em>  
                            }
                        </span>
                            <table>
                                <tbody>
                                    <tr>
                                        @{
                            if (diyitem != null)
                            {
                                            <td class="name" id="selName_@(item.ID)"><span title="@diyitem.ProductName">@diyitem.ProductName.Cut(20)</span></td>
                                            <td class="num" id="selNum_@(item.ID)"><span>@diyitemCount</span></td>
                                <td class="price" id="selPrice_@(item.ID)"><b>@diyitem.Price</b>
                                                                                   @if (diyitemCount > 1)
                                                                                   {
                                                                                       <span>x@(diyitemCount)</span>
                                                                                   }
                                                                           </td>
                                            <td id="selOp_@(item.ID)"><a class="cansel" href="/admin/diy/moni?remove=@item.ID">取消</a> </td>
                            }
                            else
                            {
                                            <td class="name" id="selName_@(item.ID)"></td>
                                            <td class="num" id="selNum_@(item.ID)"></td>
                                            <td class="price" id="selPrice_@(item.ID)"></td>
                                            <td id="selOp_@(item.ID)"></td>
  
                            }
                            
                                        }
                                    </tr>
                                </tbody>
                            </table>
                            <i></i></li>
                            }
                        }
                    }
                </ul>
                <div class="price_total">
                    <span class="tips"><em>*</em> 号为必选项</span> <strong>合计：<span class="price">&#165; <b id="allPriceTxt">@ViewBag.totalPrice</b></span></strong></div>
                <form  method="post"  id="diyForm">
                    <input type="hidden" name="totalPrice" value="@ViewBag.totalPrice"/>
                    <ul id="formPostArea" class="post_the_card">
                        
                        <li><label>配置单类型：</label>
                            @Html.DropDownList("DiyOrderType")
                        </li>
                        <li class="val_msg" id="cateId_val"><label>&nbsp;</label> <span>请选择配置单类型</span> </li>
                        <li class="val_msg" id="comments_val"><label>&nbsp;</label> <span>请填写配置单名称</span> </li>
                        <li><label>配置单说明：</label> <textarea name="remark" id="remark" cols="30" rows="4"></textarea>
                        </li>
                        <li>
                            <div class="clearfix">
                                <input type="button" id="postBtn" class="postbtn" value="提交配置单">
                            </div>
                        </li>
                    </ul>
                </form>
             
            </div>
            <div class="choose_area">
                <div class="choose_form_hd">
                    <h3>请选用 @ViewBag.curCagetoryName</h3>
                </div>
                <div class="choose_form">
                    <form id="searchProduct" action="/admin/diy/moni" method="POST">
                    <input type="hidden" name="categoryId" id="categoryId" value="@ViewBag.curCategoryId"/>
                    <ul class="choose_item clearfix">
                        <li><span>接口类型：</span>
                            @Html.DropDownList("InterfaceType", (IEnumerable<SelectListItem>)ViewBag.InterFaceTypeList, "请选择产品接口")
                        </li>
                        <li><span>价格区间：</span>
                            <select id="priceId" name="priceId">
                                <option selected="selected" value="-1">不限</option>
                                <option value="0">300元以下</option>
                                <option value="300">300-400元</option>
                                <option value="400">400-500元</option>
                                <option value="500">500-600元</option>
                                <option value="600">600-700元</option>
                                <option value="700">700-800元</option>
                                <option value="800">800-900元</option>
                                <option value="900">900元以上</option>
                            </select>
                        </li>
                        <li><span>搜产品名：</span> <span class="ostext"><input id="keyword" name="keyword" value="@ViewBag.keyword" maxlength="20" type="text" /> </span><input id="osbtn" class="osbtn" value="搜索" type="submit"> </li>
                    </ul>
                    </form>
                </div>
                <div id="choose_result" class="choose_result">
                    <div class="result_hd">
                        <strong>已找到的 @ViewBag.curCagetoryName</strong>（1067个）
                    </div>
                    <div class="result_title">
                        产品型号/价格
                    </div>
                    <ul class="result_list">
                        @foreach (var item in Model)
                        {
                            <li>
                                <h4>
                                    <a href="javascript:void(0)" title="@item.Product.Title" target="_blank">@item.Product.Title.Cut(50)</a></h4>
                                <ul class="param clearfix">
                                    <li>价格：<span class="price">&#165;&nbsp;<b>@item.LSPrice</b></span></li>
                                    <li>接口：@{
                            if (item.Product.ProductInterfaceType != null)
                            {
                                foreach (var interfaceType in item.Product.ProductInterfaceType)
                                {
                                        <span>@interfaceType.InterfaceType.Model</span>
  
                                }
                            }
                                    }
                                    </li>
                                </ul>
                                <a id="@item.Product.ID" name="xybtn" class="selbtn" href="/admin/diy/moni?sel=@item.Product.ID,@item.LSPrice,@item.Product.Title,@item.Product.Category_ID,@item.Product.Warrant" rel="@item.Product.ID,@item.LSPrice,@item.Product.Title,@item.Product.Category_ID">选用</a> </li>
                        }
                    </ul>
                    <div class="pagebar">
                        <span class="sel"><span>1</span></span><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_2.html" target="_self"><span>2</span></a><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_3.html" target="_self"><span>3</span></a><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_4.html" target="_self"><span>4</span></a><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_5.html" target="_self"><span>5</span></a><span><span class="bgno">...</span></span><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_107.html" target="_self"><span>107</span></a><a href="http://zj.zol.com.cn/proFilter/sub5_m0_gnoPrice__k_1_1_2.html" target="_self"><span class="next">下一页&gt;</span></a></div>
                </div>
            </div>
            <div class="diy_box_bottom">
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $('#topSubSel_' + @ViewBag.curCategoryId).addClass("cur");
        $('#leftSubSel_' + @ViewBag.curCategoryId).addClass("cur");
        $('#priceId').children("[value='@ViewBag.priceId']").attr('selected',true);
        
        $("[id*='topSubSel_']").bind('click', function() {
            var cId = $(this).attr("rel");
            $("#categoryId").val(cId);
            $(this).siblings(".cur").removeClass('cur');
            $(this).addClass("cur");
            $("#searchProduct").submit();
        });
        

        $(".leftSubSel").bind('click', function() {
            var cId = $(this).attr("rel");
            $("#categoryId").val(cId);
            $(this).siblings(".cur").removeClass('cur');
            $(this).addClass("cur");
            $("#searchProduct").submit();
        });
        $('#postBtn').bind('click', function() {
            
         $.post("/admin/diy/SaveDiyOrder", $("#diyForm").serialize(),
                   function(data){
                       if(data.message==null) {
                           alert("保存成功");
                       } else {
                           alert(data.message);
                       }
                   });
        });

     
    </script>
</body>
</html>
